layui.use(['element','jquery'],function(){
	var element=layui.element,
	$=layui.jquery;

	//监听导航点击
	element.on('nav(leftNav)',function(data){
		var id = data.attr('data-id');
		var url = data.attr('data-url');
		var text = data.attr('data-text');
		console.log(id+"//"+text+"//"+url);
		if(!url){
			return;
		}
		var isActive = $('.main-layout-tab .layui-tab-title').find("li[lay-id=" + id + "]");
		console.log(isActive);
		if(isActive.length > 0){
			//切换到选项卡
			console.log(1);
			element.tabChange('tabs',id);
		}else{
			console.log(2);
			element.tabAdd('tabs',{
				title:text,
				content:'<iframe src="'+url+'" width="100%" height="100%" name="iframe"'+id+' scrolling="auto" data-id="'+id+'" class="iframe" framborder="0"></iframe>',
				id:id
			});
			element.tabChange('tabs',id);
		}
	});
});